package com.dailyblue.java.standard.thread.created;

import java.util.concurrent.Callable;

// 线程的第三种实现方式
/*
    1. 实现Callable接口
    2. 重写call方法
 */
public class ThreadCreatedC implements Callable<String> {
    // 比run方法强大一些，能够返回结果
    public String call() throws Exception {
        String name = Thread.currentThread().getName();
        int sum = 0;
        for (int i = 1; i < 11; i++) {
            System.out.println(name + ":" + i);
            sum += i;
        }
        return name + ":" + sum;
    }
}
